#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int smallestNumber(int n, int t) {
        for (int i = n; ; ++i)
        {
            if (numSum(i) % t == 0)
            {
                return i;
            }
        }

        return -1;
    }

    int numSum(int n)
    {
        if (n < 10)
            return n;

        return (n % 10) * numSum(n / 10);
    }
};